package com.lksoft.bz;

import java.util.LinkedHashMap;

import javax.swing.AbstractListModel;

public class LinkedMapWrapperModel<K, V> extends AbstractListModel<V> {
	private static final long serialVersionUID = 4304496107652332021L;
	
	private LinkedHashMap<K, V> dataSource;

	public LinkedMapWrapperModel(LinkedHashMap<K, V> dataSource) {
		this.dataSource = dataSource;
	}


	@SuppressWarnings("unchecked")
	@Override
	public V getElementAt(int index) {
		return (V) dataSource.values().toArray()[index];
	}

	@Override
	public int getSize() {
		return dataSource.size();
	}

	public void fireChange(){
		fireContentsChanged(this, 0, getSize()-1);
	}
}
